package com.zfc.life.controller.backend;

import com.github.pagehelper.PageInfo;
import com.sun.org.apache.xpath.internal.operations.Mod;
import com.zfc.life.domain.Resource;
import com.zfc.life.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author zfc
 * @Date 2024/5/27 13:51
 * @Description PageController
 */
@Controller
@RequestMapping("/backend")
public class BackendPageController {
    String prefix = "backend/";

    @GetMapping("/index")
    public String index() {
        return prefix + "index";
    }

    @Autowired
    private ResourceService resourceService;

    @GetMapping("/listSubject")
    public String listSubject() {

        return prefix + "listSubject";
    }

    @GetMapping("/addSubject")
    public String addSubject() {
        return prefix + "addSubject";
    }

    @GetMapping("/modifySubject/{id}")
    public String querySubjectById(@PathVariable Long id, ModelMap mmap) {
        Resource subject = resourceService.querySubjectById(id);
        mmap.put("subject", subject);
        return prefix + "modifySubject";
    }

    @GetMapping("/addSubjectDetail/{id}")
    public String addSubjectDetail(@PathVariable Long id,ModelMap mmap) {
        mmap.put("parent",id);
        return prefix + "addSubjectDetail";
    }

    @GetMapping("/listBeautiful")
    public String listBeautiful() {
        return prefix + "listBeautiful";
    }

}
